package topic

import (
	"net/http"

	"community-service/cmd/api/internal/logic/topic"
	"community-service/cmd/api/internal/svc"
	"community-service/cmd/api/internal/types"
	"community-service/pkg/resultx"
	"github.com/zeromicro/go-zero/rest/httpx"
)

func ListTopicHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.TopicReq
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := topic.NewListTopicLogic(r.Context(), svcCtx)
		resp, err := l.ListTopic(&req)
		resultx.HttpResult(r, w, resp, err)
	}
}
